package com.mysoft.bmsdataexchange.web.controller;

import com.mysoft.bmsdataexchange.entity.Transaction;
import com.mysoft.bmsdataexchange.service.DataExchangeService;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class TestController {

    @Autowired
    private DataExchangeService dataExchangeService;

    @RequestMapping(value = "/test",method = RequestMethod.GET)
    public List<String> hi() {
        List<String> list = new ArrayList<>();
        list.add("zhangsan");
        list.add("wangwu");
        list.add("lisi");
        return list;
    }

    @RequestMapping(value = "/hi",method = RequestMethod.GET)
    public Map<String, Object> test() {
        Map<String, Object> map = new HashMap<>();
        map.put("name", "admin");
        map.put("password", "123456");
        map.put("node", "8071");
        return map;
    }


    @RequestMapping(value = "create", method = RequestMethod.GET)
    public String create() {
        String result = "success";
        try {
            Transaction bean = new Transaction();
            bean.setTransactionId("LQBZ1234");
            bean.setAssignee("zhangsan");
            bean.setCreateDateTime(20180901080911L);
            bean.setTaskStatus("Pause");
            bean.setPause(1);
            dataExchangeService.create(bean);
        } catch (Exception e) {
            e.printStackTrace();
            result = "exception";
        }
        return result;
    }
}
